// $Id: values.cpp 2 2009-09-02 08:47:42Z joseph2002 $
/*
 * Copyright 2009 Joseph Wu
 * Distributed under the Boost Software License, Version 1.0.
 * (See accompanying file LICENSE_1_0.txt or http://www.boost.org/LICENSE_1_0.txt)
 *
 * For more information, see http://xpcomplus.sourceforge.net
 */

#include <boost/test/unit_test.hpp>
#include <xpcom/result.hpp>
#include <xpcom/result_code.hpp>

BOOST_AUTO_TEST_CASE(test_values)
{
    using namespace xpcom;

    result r1 = NS_ERROR_FILE_IS_LOCKED;
    result r2 = NS_SUCCESS_LOSS_OF_INSIGNIFICANT_DATA;
    result r3(result::severity_success, 10, 20);
    result r4(result::severity_error, 200, 100);

    XPCOM_DEFINE_RESULT(_r5, result::severity_error, 10, 20);
    XPCOM_DEFINE_RESULT_S(_r6, 10, 20);
    XPCOM_DEFINE_RESULT_E(_r7, 10, 20);

    result r5 = _r5;
    result r6 = _r6;
    result r7 = _r7;

    BOOST_CHECK(r1.severity() == result::severity_error);
    BOOST_CHECK(r1.module() == NS_ERROR_MODULE_FILES);
    BOOST_CHECK(r1.code() == 14);

    BOOST_CHECK(r2.severity() == result::severity_success);
    BOOST_CHECK(r2.module() == NS_ERROR_MODULE_XPCOM);
    BOOST_CHECK(r2.code() == 1);

    BOOST_CHECK(r3.severity() == result::severity_success);
    BOOST_CHECK(r3.module() == 10);
    BOOST_CHECK(r3.code() == 20);

    BOOST_CHECK(r4.severity() == result::severity_error);
    BOOST_CHECK(r4.module() == 200);
    BOOST_CHECK(r4.code() == 100);

    BOOST_CHECK(r5.severity() == result::severity_error);
    BOOST_CHECK(r5.module() == 10);
    BOOST_CHECK(r5.code() == 20);

    BOOST_CHECK(r6.severity() == result::severity_success);
    BOOST_CHECK(r6.module() == 10);
    BOOST_CHECK(r6.code() == 20);

    BOOST_CHECK(r7.severity() == result::severity_error);
    BOOST_CHECK(r7.module() == 10);
    BOOST_CHECK(r7.code() == 20);
}
